package org.rcgwt.client.ui.validator.impl;

import org.rcgwt.client.ui.validator.IClientValidatorContext;
import org.rcgwt.client.ui.validator.IConverter;
import org.rcgwt.client.ui.validator.ISingleton;
import org.rcgwt.client.ui.validator.IValidatorElement;

import com.google.gwt.user.client.ui.Widget;

/**
 * A typed Long Converter. It can return a object representation of a string.
 * 
 * @author Elian ORIOU
 */

public class LongConverter implements IConverter<Long>, ISingleton {

	private static final LongConverter INSTANCE = new LongConverter();

	protected LongConverter() {
		
	}

	@Override
	public Long getAsObject(IClientValidatorContext context, Widget component,
			String value) {
		return Long.valueOf(value);
	}

	@Override
	public String getAsString(IClientValidatorContext context,
			Widget component, Long value) {
		return value.toString();
	}

	public static IValidatorElement getInstance() {
		return INSTANCE;
	}
}
